<template>
	<view class="container">
		<view>
			这是一个自定义组件
		</view>
		<view>
			这是父组件传递过来的数据{{title}},{{name}}
		</view>
		<view>
			<button type="primary" @click="sendNum">给父组件传值</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				num: 123 // 定义num变量，否则sendNum中无法使用
			};
		},
		props:['title','name'],
		methods:{
			sendNum(){
				console.log('给父组件传值');
				this.$emit('myEven', this.num)
			}
		},
		beforeCreate(){
			console.log('实例已经开始初始化了')
			console.log(this.num);
		},
		created(){
			console.log('created', this.num)
		},
		beforeMount(){
			console.log('beforemount', document.getElementById('myView'))
		},
		mounted(){
			console.log('mount', document.getElementById('myView'));
		},
		destroyed(){
			console.log('组件销毁了');
		}
	}
</script>

<style>
</style>